package com.aistar.config;



import com.aistar.service.redis_collect_liked.LikedCollectService;
import lombok.extern.slf4j.Slf4j;
//import org.apache.commons.lang.time.DateUtils;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.quartz.QuartzJobBean;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 点赞的定时任务
 */
@Slf4j
public class C_LikeTask extends QuartzJobBean {

    @Autowired
    LikedCollectService likedService;

    private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    @Override
    protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        Logger log = LoggerFactory.getLogger(getClass());
        log.info("C_LikeTask-------- {}", sdf.format(new Date()));
        System.out.println("C_LikeTask-------- {}"+sdf.format(new Date()));
        //将 Redis 里的点赞信息同步到数据库里
        likedService.transLikedFromRedis2DB();
//        likedService.transLikedCountFromRedis2DB();
    }
}